package lab03.test01;

import java.io.*;

public class Test01 {
    public static void main(String[] args) {
        String path = "F:\\Hello.txt";     //文件的绝对路径
        //只读一行
        try {
            BufferedReader reader = new BufferedReader(new FileReader(path));
            String line = reader.readLine();
            System.out.println(line);
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //读取整个文件信息
        try {
            BufferedReader reader = new BufferedReader(new FileReader(path));

            while (true) {
                String line = reader.readLine();
                if (line == null) {
                    break;
                } else {
                    System.out.println(line);
                }
            }
            reader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


